package com.sumainfor.pc.epc.controller.MarketFeign;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.epc.service.impl.FeignMkt.HousingRepairService;
import com.sumainfor.pc.epc.service.impl.RepairServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 功能描述:
 *
 * @Auther: zhlu
 * @Date: 2019/3/8 20:09
 * @Description:
 */
@RestController
@RequestMapping("/key/repair")
public class HousingRepairContoller {

    @Autowired
    HousingRepairService HousingRepairService;

    @Autowired
    RepairServiceImpl RepairServiceImpl;

    /**
     * 功能描述: 
     * 管家新增维修工单
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/3/8 20:12
     */
    @ResponseBody
    @RequestMapping(value = "/AddRepair",method= RequestMethod.POST)
    public boolean AddRepair(@RequestBody Map<String,Object> params){
        boolean result=false;
        if(HousingRepairService.AddRepair(params)){
            result=true;
        }
        return result;
    }

    /**
     * 功能描述: 
     * 根据管家巡房主编号获取管家维修集合
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/3/9 15:05
     */
    @GetMapping("/getHousingRepairList")
    public List<Map<String,Object>>getHousingRepairList(@RequestParam Map<String,Object>params){
        List<Map<String,Object>>getHousingRepairList=HousingRepairService.getHousingRepairList(params);
        return getHousingRepairList;
    }

    /**
     * 功能描述: 
     * 市场部经理获取维修中房源
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/4/16 20:16
     */
    @GetMapping("/getMatketRepairHousing")
    public JsonResult getMatketRepairHousing(){
        JsonResult result=new JsonResult();
        return result.put(HousingRepairService.getMatketHousing());
    }

    /**
     * 功能描述:
     * 工程助理维修工单池
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/9 11:22
     */
    @PostMapping("/getManagerRepairList")
    public JsonResult getManagerRepairList(@RequestBody Map<String,Object> params){
        JsonResult result=new JsonResult();
        PageUtils pageUtils = new PageUtils();
        Integer cout= RepairServiceImpl.getManagerRepairListCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>> getManagerRepairList=RepairServiceImpl.getManagerRepairList(params);
        result=pageUtils.getJsonResult(getManagerRepairList, params, cout);
        return result;
    }




}
